package com.petlab.dao.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;

import com.petlab.dao.ArticleDao;
import com.petlab.model.Article;
import com.petlab.model.User;

@Component("articleDao")
public class ArticleDaoImpl implements ArticleDao {

	private HibernateTemplate hibernateTemplate;

	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}

	@Resource
	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}

	public void forumSave(Article article,ArrayList<User> user) {
		hibernateTemplate.save(article);
	}

	public Article getArticle(int articleId) {
		// TODO Auto-generated method stub
		List<?> list = hibernateTemplate
				.find("from Article article where article.articleId = '"
						+ articleId + "'");
		return (Article) list.get(0);
	}

}
